/**
 * Project Name:bts-manage-api
 * File Name:PageRequest.java
 * Package Name:cn.easysw.bts.manage.api.request
 * Date:2018年6月15日上午11:02:26
 * Copyright (c) 2018, www.windo-soft.com All Rights Reserved.
 */

package ink.tiptop.common.domain.rsp;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import ink.tiptop.common.domain.ListBody;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
@Getter
@Setter
public class PageResponse<T> extends ListResponse<T> {

    private static final long serialVersionUID = -1691175452100829052L;
    // 总页数
//    @JsonProperty("rows")
//    private long rows = 0;

    // 总数
    @JsonProperty("TOTAL")
    private long total = 0;

    // 1.设置为 ‘limit’ 则会发送符合 RESTFul 格式的参数.
    @JsonProperty("LIMIT")
    private String limit = "limit";

    // 2.页码
    @JsonProperty("OFFSET")
    private long offset = 0;

    // 3.search 是否启用搜索框
    @JsonProperty("SEARCH")
    private Boolean search = true;

    // 4.定义排序的列名
    @JsonProperty("SORT")
    private String sort = "ID";

    // 5.排序方式 该列默认的排序方式， ‘asc’ or ‘desc’.
    @JsonProperty("ORDER")
    private String order = "desc";


    public PageResponse(ListBody<T> body) {
        super(body);
    }

    public PageResponse(List<T> list) {
        super(list);
    }

    public PageResponse(List<T> list, int count) {
        super(list, count);
    }

    public PageResponse<T> total(long total) {
        this.total = total;
        return this;
    }

    public PageResponse<T> offset(long offset) {
        this.offset = offset;
        return this;
    }
}

